<template>
  <el-container>
    <el-header>
      <div style="width: 100%">
        <navigator></navigator>
      </div>
    </el-header>
    <el-main class="detail-main">
      <el-card class="detail-card">
        <img class="picture" src="@/assets/home/challengePicture.jpg">
        <h1 class="challengeName">{{ challengeInfo.challengeName }}</h1>
        <el-button type="primary" plain class="compete" @click="dialogFormVisible = true" :disabled="disabled">{{ buttonText }}</el-button>
        <el-tabs type="border-card" class="menu">
          <el-tab-pane label="简介" class="pane" >
            <el-descriptions :title="challengeInfo.challengeName" class="el-descriptions">
              <el-descriptions-item label="开始时间：">{{ challengeInfo.startTime }}</el-descriptions-item>
              <el-descriptions-item label="结束时间：">{{ challengeInfo.endTime }}</el-descriptions-item>
              <el-descriptions-item label="股票代码：">{{ challengeInfo.stockCode }}</el-descriptions-item>
              <el-descriptions-item label="起始资金：">{{ challengeInfo.startingFunds }}</el-descriptions-item>
              <el-descriptions-item label="最大参赛人数：">{{ challengeInfo.maxParticipantsNumber }}</el-descriptions-item>
              <el-descriptions-item label="参赛人数：">{{ challengeInfo.participantsNumber }}/{{ challengeInfo.maxParticipantsNumber }}</el-descriptions-item>
            </el-descriptions>
            <el-divider class="divider1"></el-divider>
            {{ challengeInfo.introduction }}
          </el-tab-pane>
          <el-tab-pane label="数据">
            <p1 class="startDate">开始日期</p1>
            <p1 class="start">{{ challengeInfo.startTime }}</p1>
            <p1 class="finishDate">结束日期</p1>
            <p1 class="finish">{{ challengeInfo.endTime }}</p1>
            <div>
              <el-progress :text-inside="true" :stroke-width="26" :percentage="per" class="process"></el-progress>
            </div>
            <el-divider class="divider"></el-divider>
            <div class="nowEcharts" id="nowEcharts">
            </div>
          </el-tab-pane>
          <el-tab-pane label="排名">
            <el-table
              :data="tableData.slice((curPage-1)*eachPage,curPage*eachPage)"
              style="width: 100%">
              <el-table-column
                type="index"
                label="排名"
                width="120">
              </el-table-column>
              <el-table-column
                prop="userId"
                label="用户ID"
                width="120">
              </el-table-column>
              <el-table-column
                prop="account"
                label="用户"
                width="500">
              </el-table-column>
              <el-table-column
                prop="yield"
                label="收益率">
              </el-table-column>
            </el-table>
            <el-pagination align='center'
                           @size-change="handleSizeChange"
                           @current-change="handleCurrentChange"
                           :current-page="curPage"
                           :page-sizes="[10,20]"
                           :page-size="eachPage"
                           layout="sizes, prev, pager, next, jumper"
                           :total="tableData.length">
            </el-pagination>
          </el-tab-pane>
        </el-tabs>
        <el-dialog title="请选择条件单" v-model="dialogFormVisible">
          <el-form :model="form">
            <el-form-item prop="region">
              <el-select v-model="form.region" placeholder="请选择条件单" name="region">
                <el-option v-for="sheet in sheets"
                           :key="sheet.conditionSheetId"
                           :label="sheet.conditionSheetName"
                           :value="sheet.conditionSheetId"></el-option>
              </el-select>
            </el-form-item>
          </el-form>
          <template #footer>
    <span class="dialog-footer">
      <el-button @click="dialogFormVisible = false">取 消</el-button>
      <el-button type="primary" @click="signForChallenge">确 定</el-button>
    </span>
          </template>
        </el-dialog>
      </el-card>
    </el-main>
  </el-container>
</template>

<script lang="ts" src="./challengeDetail.ts">

</script>

<style scoped>
.el-header{
  padding-inline-end: 0px;
  padding-inline-start: 0px;
}

.detail-card{
  position: absolute;
  width: 1000px;
  height: auto;
  left: 300px;
}
.picture{
  width: 100%;
  height: 200px;
  left: 0;
}
.menu{
  margin-top: 110px;
  height: auto;
}
.challengeName{
  font-size: 36px;
  color: aliceblue;
  margin-top: -150px;
}
.compete{
  position: absolute;
  margin: 0;
  left: 850px;
}
.pane{
  height: 500px;
}
.startDate{
  position: absolute;
  margin: -75px -450px;
}
.start{
  position: absolute;
  margin: -40px -450px;
}
.finishDate{
  position: absolute;
  margin: -75px 300px;
  width: 200px;
}
.finish{
  position: absolute;
  margin: -40px 300px;
  width: 200px;
}
.process{
  margin: 100px 10px;
  width: 900px;
}
.divider{
  position: absolute;
  margin: -60px 10px;
  width: 900px;
}
.divider1{
  position: absolute;
  margin: 0px 5px;
  width: 900px;
}
.nowEcharts {
  width:1000px;
  height:500px;
}
</style>
